// Fill out your copyright notice in the Description page of Project Settings.

#include "Isalong2.h"
#include "BuildingFullSnapLogic.h"




UBuildingFullSnapLogic::UBuildingFullSnapLogic()
{
	_useLogicTick = true;
}

void UBuildingFullSnapLogic::LogicTick(float DeltaTime)
{
	if (!_compOwner->GetIsPlaced())
	{
		if (_compOwner->ToolEdgeSnap())
		{
			_compOwner->SetCanPlace(_compOwner->GetAroundSupportValue() > 0);
			return;
		}
		if (_compOwner->ToolGetPositionIndex() != -1)
		{
			auto index = _compOwner->ToolGetPositionIndex();
			switch (index)
			{
			case 4:
				_compOwner->ToolUpSnap();
				_compOwner->SetCanPlace(_compOwner->GetAroundSupportValue() > 0);
				return;
			case 1:case 0:case 2:case 3:
				_compOwner->ToolSideSnap(index);
				_compOwner->SetCanPlace(_compOwner->GetAroundSupportValue() > 0);
				return;
			}
		}
		if (_compOwner->ToolFootSnap())
		{
			_compOwner->SetCanPlace(_compOwner->GetAroundSupportValue() > 0);
			return;
		}
		if (_compOwner->ToolLandSnap())
		{
			_compOwner->SetCanPlace(true);
			return;
		}
		_compOwner->SetCanPlace(false);
		_compOwner->ToolGoBack();
	}
}
